from django.urls import path
from rest_framework_jwt.views import obtain_jwt_token
from apps.meiduo_admin.views import statistical, users, goods,images,skus,orders,perms,groups,admins

urlpatterns = [
    # 登录
    path(r'authorizations/', obtain_jwt_token),
    # -----------------------数据统计--------------------
    # -----------------------用户总数统计--------------------
    path(r'statistical/total_count/', statistical.UserTotalCountView.as_view()),
    # -----------------------日增用户统计--------------------
    path(r'statistical/day_increment/', statistical.UserDayIncrementView.as_view()),
    # -----------------------日活用户统计--------------------
    path(r'statistical/day_active/', statistical.UserDayActiveView.as_view()),
    # -----------------------日下单用户统计--------------------
    path(r'statistical/day_orders/', statistical.UserDayOrdersView.as_view()),
    # -----------------------月新增用户统计--------------------
    path(r'statistical/month_increment/', statistical.UserMonthIncrement.as_view()),
    # -----------------------商品访问量统计--------------------
    path(r'statistical/goods_day_views/', statistical.GoodsDayViews.as_view()),

    # -----------------------用户管理路由--------------------
    path(r'users/', users.UsersViews.as_view()),

    # -----------------------商品管理路由--------------------
    # -----------------------规格表路由--------------------
    # path(r'goods/specs/', goods.GoodsSpecViews.as_view({'get': 'list'})),
    path(r'goods/simple/', goods.GoodsSpecViews.as_view({'get': 'simple'})),
    path(r'skus/simple/', images.SKUImageViews.as_view({'get': 'simple'})),

    # 获取商品的规格信息
    path(r'goods/<int:pk>/specs/', skus.SKUSViews.as_view({'get': 'specs'})),

    #---------------------订单管理------------------------
    path(r'orders/', orders.OrderView.as_view()),
    path(r'orders/<int:pk>/', orders.OrderDetailView.as_view()),
    path(r'orders/<int:pk>/status/', orders.OrderDetailView.as_view()),

    # 获取权限类型 PermsView视图集
    path(r'permission/content_types/', perms.PermsView.as_view({'get':'content_types'})),
    # 获取简单权限
    path(r'permission/simple/', groups.GroupsView.as_view({'get':'simple'})),
    path(r'permission/groups/simple/',admins.AdminsView.as_view({'get':'simple'})),





]

# 视图集可以采用自动生成路由类
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
# 规格表
router.register('goods/specs', goods.GoodsSpecViews, basename='googdspecs')

# 图片表
router.register('skus/images', images.SKUImageViews, basename='skuinage')

router.register('skus', skus.SKUSViews, basename='skus')

# 权限表
router.register('permission/perms', perms.PermsView, basename='perms')
# 分组表
router.register('permission/groups', groups.GroupsView, basename='groups')
# 管理员
router.register('permission/admins', admins.AdminsView, basename='admins')
urlpatterns += router.urls
